package com.qianwei.footpath.presenter;

import com.common.baselib.bean.ResultBean;
import com.common.baselib.net.CallBackSubscriber;
import com.common.baselib.net.SubscriberOnNextListener;
import com.qianwei.footpath.base.BasePresenter;
import com.qianwei.footpath.bean.LoginUserBean;
import com.qianwei.footpath.iview.IResultView;
import com.qianwei.footpath.net.RetrofitUtil;
import com.qianwei.footpath.param.WeChatUpdateParam;

public class ResultPresenter extends BasePresenter<IResultView> {
    @Override
    public void createModel() {

    }

    public void getLoginUser(String imei) {
        RetrofitUtil.getInstance().getLoginUser(imei, new CallBackSubscriber<>(new SubscriberOnNextListener<ResultBean<LoginUserBean>>() {
            @Override
            public void onNext(ResultBean<LoginUserBean> loginUserBeanResultBean) {
                if (isViewAttached()) {
                    getView().getLoginUser(loginUserBeanResultBean.data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (isViewAttached()) {
                    getView().getLoginUser(null);
                }
            }
        }));
    }

    public void getWeChatUpdate(WeChatUpdateParam param) {
        RetrofitUtil.getInstance().getWeChatUpdate(param, new CallBackSubscriber<>(new SubscriberOnNextListener<ResultBean<Boolean>>() {
            @Override
            public void onNext(ResultBean<Boolean> booleanResultBean) {

            }

            @Override
            public void onError(int code, String msg) {

            }
        }));
    }
}
